import java.util.Arrays;
import java.util.List;

public class problem32 {
    public static void main(String[] args) {
        List<Long> pandigitalsList = Arrays.asList(ProjectEuler.getPandigitals(123456789L));

        Long sum = 0L;
        for(Long a=1L; a < 1000; a++)
            for(Long b=1L; b<1000; b++) {
                Long product = a * b;
                String concatString = a.toString() + b.toString() + product.toString();
                if(concatString.length() == 9) {
                    if(pandigitalsList.contains(Long.valueOf(concatString))) {
                        System.out.println(a + " * " + b + " = " + product);
                        sum += Long.valueOf(concatString);
                    }
                }

                if (b % 100 == 0) {
                    System.out.println(a + " * " + b + " = " + product);
                }
            }
        System.out.println(sum);
    }
}
